<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head> 
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
	<title>湖南省自来水公司营销管理信息系统</title> 
	
	<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/text.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/form.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/buttons.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/grid.css" type="text/css" media="screen" title="no title" />	
	<link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" title="no title" />	
	
	<link rel="stylesheet" href="../css/ui-darkness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/jquery.visualize.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/facebox.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/uniform.default.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/dataTables.css" type="text/css" media="screen" title="no title" />
	
	<link rel="stylesheet" href="../css/custom.css" type="text/css" media="screen" title="no title">

</head> 
 
<body> 

<div id="wrapper">
	
		
	
<div id="bool"><script>window.onload=function (){  $("#bool").load("../ming.html");}</script></div>


	
	<div id="content" class="xgrid">
		
 		
		<div class="x12">
			
			<h2>设置菜单权限</h2>
			
			<div class="form label-inline uniform xgrid">
			
				<div class="field">
					<span class="bold">正在设置以下员工的菜单权限<span> <br/>
					<span class="red" v-if="Syemps!=''">注意：你正在编辑多个员工的菜单权限，不会显示这些员工的原有权限。
							<br/>仅仅在只编辑一个员工时，才会显示该员工的原有权限。</span>
				</div>

				<div class="field">
					<textarea class="medium" disabled="disabled" style="width:100%;height:50px;"  />
					</textarea>
				</div>
				<div class="portlet x4" v-for="me in Symenus" v-if="me.parent==0">
					<div class="controlset field">
						<span class="label">{{me.menuName}}</span>
						<div class="controlset-pad">
                            <span v-for="(mua,index) in Symenus"  v-if="mua.parent==me.id">
                                <input     type="checkbox"   :checked="mua.onClick?'checked':''"  :value="mua.id" /><label >{{mua.menuName}}</label><br />
                            </span>
						</div>
					</div>
				</div>
				
				<div class="buttonrow">
					<button class="btn" @click="baochu()">保存</button>
					<button class="btn btn-grey" onClick="history.back(-1);">返回</button>
				</div>
			</div>
			
		</div> <!-- .x12 -->
		
	</div> <!-- #content -->
	
	<div id="footer">		
		<div class="content_pad">			
			<p>&copy; 2013-11 版权所有 <a href="#">湖南省自来水公司</a>.   技术支持 <a href="#">职业教育</a>.</p>
		</div> <!-- .content_pad -->
	</div> <!-- #footer -->
	
</div> <!-- #wrapper -->

<script src="../js/jquery/jquery-1.5.2.min.js"></script>
<script src="../js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="../js/misc/excanvas.min.js"></script>
<script src="../js/jquery/facebox.js"></script>
<script src="../js/jquery/jquery.visualize.js"></script>
<script src="../js/jquery/jquery.dataTables.min.js"></script>
<script src="../js/jquery/jquery.tablesorter.min.js"></script>
<script src="../js/jquery/jquery.uniform.min.js"></script>
<script src="../js/jquery/jquery.placeholder.min.js"></script>

<script src="../js/widgets.js"></script>
<script src="../js/dashboard.js"></script>
<script src="../js/vue.js"></script>
<script type="text/javascript">
    var empid = new Array();
    function  load() {
    $.getJSON("../Symenu/queryall",{},function(json){
        app.Symenus=json;
        if(app.Symen!=null){
        $.each(app.Symen,function () {
            var mun = this.menuID;
             $.each(app.Symenus,function(){
                 if(mun==this.id){
                        this.onClick=true;
                 }
            });
        });}
    });
}
var app = new Vue({
    el:"#wrapper",
    data:{
        Symenus:'',
        Symen:[],
        Syemps:'',
    },
    methods:{
        update(id){
            location="sys_menupower_set.html?id="+id;
        },
        query(){
            $("#lai").val($("#type").val());
            $("#lai").keyup();
        },
        baochu(){
            var che = $(":checkbox");
            var menuid=new Array();
            $.each(che,function(){
                if(this.checked==true){
                    menuid.push(this.value);
                }
            });
            $.getJSON("../Syempmenupower/add?empid="+empid+"&menuid="+menuid,{},function (json) {
               if(json==1){
                   alert("保存成功");
                   location="sys_menupower.html";
               }
            });
        }
    },
    //监听事件
    watch:{
        Symenus:function(){
            this.$nextTick(function(){
                $(document).ready ( function ()
                {
                    Dashboard.init ();
                });
            });
        }
    },
    created(){
        var empids  = JSON.parse(localStorage.getItem("list"));
        if(empids!=null){
            empid.push(empids);
            $.getJSON("../Syemp/queryByids?empids="+empids,{},function(json){
                app.Syemps=json;
                var str='';
                $.each(app.Syemps,function () {
                    if(app.Syemps[app.Syemps.length-1]==this){
                       str+=this.empNmae;
                    }else{
                    str+=this.empNmae+",";}
                });
                $("textarea:eq(0)").val(str);
            });
        }
        var u = new URLSearchParams(location.search);
        var id = u.get("id");
        if(id!=null){
        empid.push(id);
            $.getJSON("../Syemp/queryByid/"+id,{},function(json){
                $("textarea:eq(0)").val(json.empNmae);
            });
         $.getJSON("../Syempmenupower/querybyid/"+id,{},function(json){
             app.Symen=json;
         });
        }
        load();

    }

});


</script>

</body> 
 
</html>